home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 21
/
Cream of the Crop 21 (Terry Blount) (October 1996).iso
/
program
/
gnuview.zip
/
emx
/
book
/
emxgnu.inf
(
.txt
)
next >
Wrap
OS/2 Help File
|
1996-09-08
|
56KB
|
1,542 lines
ΓòÉΓòÉΓòÉ 1. 1 Introduction to GNU Development Tools Information ΓòÉΓòÉΓòÉ
GNU Development Tools Information
Copyright (c) 1990-1993 by Eberhard Mattes
This text describes how to use the GNU C Compiler and other GNU utilities with
emx. For detailed information about GCC, GDB, and GAS, read the GCC, GDB, and
GAS manuals, see install.doc. See build.doc for details on compiling the GNU
utilities.
All programs assume that the entire package is installed on one disk drive in
these directories:
/emx/bin Executable files
/emx/etc termcap.dat
/emx/lib Library files
/emx/include Header files (C language)
/emx/include/cpp Header files (C++ language)
/emx/include/objc Header files (Objective C language)
If the /emx directory is not on the current drive, use the C_INCLUDE_PATH and
LIBRARY_PATH environment variables, for instance
set C_INCLUDE_PATH=c:/emx/include
set LIBRARY_PATH=c:/emx/lib
to use drive C.
Use forward slashes instead of backward slashes in path names!
Directories:
/emx Main directory, empty
/emx/bin Executable files and batch files
/emx/dll Dynamic link libraries
/emx/doc Documentation
/emx/etc termcap.dat
/emx/gnu/binutils.old old GNU binary utilities (sources)
/emx/gnu/binutils.26 new GNU binary utilities (sources)
/emx/gnu/doc Documentation
/emx/gnu/duel DUEL (for GDB)
/emx/gnu/gas-2.6 GNU assembler source (GAS)
/emx/gnu/gcc-2.7 GNU C compiler source (GCC)
/emx/gnu/gdb-4.16 GNU debugger source (GDB)
/emx/gnu/gppdemid C++ demangler for LINK386
/emx/gnu/info GNU info source
/emx/gnu/libtxi -libtxi (for GNU info)
/emx/gnu/libg++-2.7.2 GNU C++ libraries
/emx/gnu/makeinfo GNU makeinfo source
/emx/gnu/termcap GNU termcap
/emx/gnu/texindex GNU texindex source
/emx/include header files (C language)
/emx/include/cpp Header files (C++ language)
/emx/include/objc Header files (Objective C language)
/emx/lib Libraries
ΓòÉΓòÉΓòÉ 2. 2 GCC -- compiling and linking C and C++ programs ΓòÉΓòÉΓòÉ
GCC 2.7.2.1 has been ported to emx, including Richard W.M. Jones's bounds
checking patches.
Calling GCC
Environment variables
Bounds checking
#pragma statement
Additional command line options
Special file extensions
Startup modules and libraries
Assertions
C++
Objective C
Stack probes
Other changes
Calling conventions
ΓòÉΓòÉΓòÉ 2.1. 2.1 Calling GCC ΓòÉΓòÉΓòÉ
For small projects, one invokation GCC can be used to compile and link the
program. Example:
gcc dwim.c
This assumes that emxl.exe can be found in one of the directories listed in
the EMXPATH and PATH environment variables, or in the directory /emx/bin, see
also ld. If no output file name is given, the name of the first input file,
with .exe extension (or .dll extension if -Zdll is given), is used for the
output file unless linking is suppressed (with the -c option, for instance).
That is, the above example creates dwim.exe.
Please note that the example given above creates a file named dwim which will
be deleted after conversion to .exe format.
If the output file name doesn't end in .exe or .dll, the output file will have
a.out format (however, see -Zexe). Example:
gcc -o dwim dwim.c
This example creates the a.out file `dwim'.
ΓòÉΓòÉΓòÉ 2.2. 2.2 Environment variables ΓòÉΓòÉΓòÉ
If you want to develop programs on a drive different from the drive where emx
is installed, you have to set the C_INCLUDE_PATH and LIBRARY_PATH environment
variables, for instance,
set C_INCLUDE_PATH=c:/emx/include
set LIBRARY_PATH=c:/emx/lib
If you want to compile C++ programs, set CPLUS_INCLUDE_PATH as well:
set CPLUS_INCLUDE_PATH=c:/emx/include/cpp;c:/emx/include
If you want to compile Objective C programs, set OBJC_INCLUDE_PATH as well:
set OBJC_INCLUDE_PATH=c:/emx/include
The genclass utility needs the following environment variable:
set PROTODIR=c:/emx/include/cpp/gen
If the TMPDIR, TMP and TEMP environment variables are not set, GCC writes
temporary files in the current working directory. GCC tries TMPDIR, TMP and
TEMP in turn and uses the first valid one. Note that c: is not a valid
directory name, you have to use c:/ or \ instead. In other cases, a trailing
slash or backslash is optional. For instance, use
SET TMPDIR=f:/tmp/
to put temporary files into the f:/tmp directory.
When compiling projects consisting of many modules (such as libraries) under
OS/2, you can speed up compilation if you have enough memory by keeping GCC in
memory. For example, to keep GCC in memory for 5 minutes, use
set GCCLOAD=5
The following programs use GCCLOAD: gcc.exe, cpp.exe, cc1.exe, cc1plus.exe,
cc1obj.exe, as.exe and emxomf.exe.
You can put GCC options into the environment variable GCCOPT. These options
will be read before the options given on the command line. For example, to
use -pipe, type
set GCCOPT=-pipe
ΓòÉΓòÉΓòÉ 2.3. 2.3 Bounds checking ΓòÉΓòÉΓòÉ
The emx port of GCC includes Richard W.M. Jones's bounds checking patches.
See the GCC manual and \emx\gnu\doc\bounds\README for details. The complete
report is in \emx\gnu\doc\bounds\bcrep2.ps (shipped in gnudoc.zip). Use
GhostScript if you don't have a PostScript printer.
\emx\gnu\doc\bounds\bcreport.txt contains important excerpts from an earlier
version of the report as plain ASCII text.
There are a few additional restrictions under OS/2:
Bounds checking is not available for multithread programs
Bounds checking is available for statically linked programs only
Bounds checking is not available for DLLs
If your program uses _tmalloc(), you have use the -ltmalloc option as the
bounds checking library check.a replaces malloc()
The header files <stdarg.h> and <varargs.h> automatically include <fix-args.h>
if bounds checking is enabled. Therefore you don't have to include
<fix-args.h> yourself.
ΓòÉΓòÉΓòÉ 2.4. 2.4 #pragma statement ΓòÉΓòÉΓòÉ
The emx port of GCC supports the
#pragma pack(n)
statement where n is 1, 2 or 4. The default is 4. Structure fields are
aligned to multiples of n bytes, according to the value n as set by the last
#pragma pack statement.
#pragma pack()
reverts to the default (4). Note that other C compilers revert to the value
in effect before the previous #pragma pack statement.
ΓòÉΓòÉΓòÉ 2.5. 2.5 Additional command line options ΓòÉΓòÉΓòÉ
Several command line options have been added to GCC:
-mepilogue
emit only one epilogue per function
-mno-epilogue
emit multiple epilogues per function if appropriate (default)
-mprobe
generate stack probes
-mno-probe
do not generate stack probes (default)
-pn
Enable profiling but do not generate profile hooks
-Zbin-files
open files in binary mode by default
-Zbsd-signals
select the `BSD' signal processing model
-Zcrtdll
link the C library dynamically
-Zdll
create a dynamic link library
-Zexe
touch output file, add .exe extension
-Zmap
let LINK386 or emxbind create a .map file
-Zlink